/*
 ============================================================================
 Name        :
 Author      :
 Version     :
 Copyright   :
 Description :  declaration
 ============================================================================
 */

#ifndef __LOGINDAEMON_H__
#define __LOGINDAEMON_H__

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <eikedwin.h>
#include <Aknnumseced.h>
#include "HttpEngine.h"
#include "fCanvas.h"

#include <e32std.h>
#include "HttpEngine.h"
#include "fWml.h"
#include "ResponseNotice.h"
#include "YuebaoBuffer.h"
#include "RSendAs_SMS.h"

class YuebaoFramework;
class SmsEngineUtility;
class MLoginObserver
{
public:
    virtual void LoginResult( TBool success, const TDesC & aMessage, TBool bIsNetworkFinshed ) = 0;
};

class LoginDaemon : public CBase, public HttpEngineObserver, public MDialogEventObserver, public MRSendSMSObserver
{
public:
    enum TNetStatus
    {
        EIdle = 0,
        EGetDispache,
        EGetDispacheFailed,
        EGetDispacheSuccess,
        EGetPhoneNumber,
        EGetPhoneNumberFailed,
        EGetPhoneNumberSuccess,
        ERegiste,
        EMidConfirmFailed,
        EMidConfirmSuccess,
        EGetHomepage,
        EGetHomepageFailed,
        EGetHomepageSuccess,
        EGetNotice,
        EGetNoticeFaild,
        EGetNoticeSuccess,
        EGetDateFromServer,
        EGetDateFromServerFailed,
        EGetDateFromServerSuccess,
        EGetUpdateInformation,
        EGetVersionInformation,
        EGetSISXForceUpdate,
        EGetSISXAdviceUpdate,
        EDownloadSISXfile,
        EAdviceUserToupdate,
        EDownloadResfile,
        EUpdating,
        EUpdated,
        EGetCityID,
        EExitApp,
        EModifyPassword
    };
public:
    ~LoginDaemon();
    static LoginDaemon *NewL( YuebaoFramework *aEngine );
    static LoginDaemon *NewLC( YuebaoFramework *aEngine );
private:
    LoginDaemon();
    void ConstructL( YuebaoFramework *aEngine );
public:
    void Start()
    {
        DoDispache();
    }

private:
    //void StartLogin();
    void DoDispache();
public:
    void SetLoginObersver( MLoginObserver *aMLoginObserver );
protected:
    void SkipWappageTips( const TDesC8 & aBodyData );
private:
    void HttpFinished( const CHttpEngine & engine, int finishedReason, const TDesC8 & aBodyData );
private:
    void SaveNoticeData( CResponseDispacher *notice );
    void GetHomepage();
    void Register( const TDesC& phoneNumber );
    void GetPhoneNumber( const TDesC& whitelistUrl );
    void SendRegisterMessage( const TDesC& MessagerCenter );
    void InstallSisx( const TDesC& path );
protected:
    void HandleReturnEvent( fDialog* aObject, TReturnValue aValue );
    char* HttpEngineObserverID()
       {
           return "LoginDaemon";
       }
    virtual void MessageSentL( TInt aError );
private:
    YuebaoFramework *iFramework;
    CHttpEngine *iNetEngine;
    SmsEngineUtility *ifSmsEngine;
    CRSendAsSender* _smsSender;
    CResponseDispacher* _notice;
private:
    TNetStatus iNetStatus;
    TInt iTryCount;
    TBool bWapReg;
    TBool iIsFirstStart;
    TBool iIsFirstShow;
    TBool iIsCancel;
    TInt iUserStep;
private:
    MLoginObserver *iMLoginObserver;
};

#endif // __VIVA_CVS_LOGIN_H__
